package LuoGu;

import java.util.*;

public class P1012 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        Integer[] arr=new Integer[n];
        for(int i=0 ;i<n ;i++){
            arr[i]=sc.nextInt();
        }
        Arrays.sort(arr, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                if(o1==o2){
                    return 0;
                }
                int tmpO1=o1;
                int tmpO2=o2;
                int o1Index=getIndex(o1);
                int o2Index=getIndex(o2);
                int tmp1=0;
                int tmp2=0;
                while (o1 != 0 && o2 != 0) {
                    tmp1 = o1 / o1Index;
                    tmp2 = o2 / o2Index;
                    if (tmp1 != tmp2) {
                        break;
                    }
                    o1 %= o1Index;
                    o2 %= o2Index;
                    o1Index /= 10;
                    o2Index/=10;
                }
                if(o1==0){
                    int num1=tmpO1/getIndex(tmpO1);
                    int num2=tmpO2%10;
                    return num1>num2? -1:1;
                }else if(o2==0){
                    int num2=tmpO2/getIndex(tmpO2);
                    int num1=tmpO1%10;
                    return num2>num1?1:-1;
                }
                 return tmp2-tmp1;
            }
        });
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
        }
    }
    public static int getIndex(int num){
        int sum=1;
        while(num!=0){
            num/=10;
            sum*=10;
        }
        return sum/10;
    }
}
